﻿
@{
    ViewBag.Title = "ChooseInvoiceNo";
    Layout = "~/Views/Shared/_Form.cshtml";

    var from = (ViewBag.from as string) ?? "";
}

<form id="formReceipt">
    <div style="margin-top:40px;margin-right:40px;">
        <table class="form">
            <tr>
                <th class="formTitle dialogText">发票号:</th>
                <td class="formValue">
                    <input type="text" class="form-control" id="txtfph" name="txtfph" required value="">
                </td>
            </tr>
        </table>
    </div>
</form>

<script>
    //上一个window对象
    var prevWindow;
    if ('@(from)' != '') {
        prevWindow = top.top.frames['@(from)'];
        debugger
    }
    else {
        prevWindow = $.currentWindow();
    }

    $.ajax({
        url: "/BusinessManage/OutPatient/GetInvoice",  //获取
        dataType: "json",
        async: false,
        success: function (data) {
            $("#txtfph").val(data);
            prevWindow.$("#txtfph").val(data);
        }
    });

    //确认验证发票号
    function checkFPH() {
        $.loading(true, '发票验证中...');
        $.ajax({
            url: "/BusinessManage/OutPatient/CheckInvoice",
            data: { inputFPH: $("#txtfph").val() },
            type: "POST",
            dataType: "json",
            async: false,
            success: function (data) {
                $.loading(false);
                if (data.state == "success") {
                    prevWindow.$("#txtfph").val($("#txtfph").val());
                    $.modalClose();
                }
                else {
                    prevWindow.$("#txtfph").val("");
                    $.modalMsg(data.message, data.state);
                }
            },
            error: function (data) {
                $.modalMsg(data.message, data.state);
            },
            complete: function () {
                $.loading(false);
            }
        });
    }

</script>
